﻿@{
    Layout = null;
    var plugName = @user.admin.cyt369.com.Areas.UserAdmin.Models.PlugName.Name;
    var tableName = PageViewModel.PageTableID(this);
    var tableToolBar = PageViewModel.PageTableToolbar(this);

    var editFunName = PageViewModel.PageFunctionName(this, "edit_terms");
    var editDlgName = PageViewModel.PageEditDialog(this);
    var deleteFunName = PageViewModel.PageFunctionName(this, "delete_terms");
}

<div style="height:100%">
    <script type="text/javascript">
        function @editFunName (id) {
            var dlg = $dlg('@editDlgName');
            dlg.dialog({
                title: '协议信息', width: 900, height: 550,
                closed: false, cache: false, modal: true, maximizable: true, resizable: true, maximized: true,
                href: '~/@plugName/Terms/_EditTermsDlg?dlg=@editDlgName&tbl=@tableName&ID=' + id,
                onResize: function () {
                    $(this).dialog('center');
                },
                onClose: function () {
                    UE.getEditor('terms-editor-text-area').destroy();
                },
            });
        }

        function @deleteFunName (id) {
            if (id > 0 && confirm("确认删除协议资料?")) {
                $.ajax({
                    async: false,
                    method: "DELETE",
                    url: $.Content("~/@plugName/Terms/DeleteTerms/" + id),
                    context: $("#@tableName"),
                    success: function (e) {
                        if (e.Result) {
                            this.datagrid('reload');
                        } else {
                            $.messager.alert('删除数据', '删除失败: ' + e.Msg, 'error');
                        }
                    },
                    error: function (e1, e2, e3) {
                        ShowAjaxError(e1, "删除数据");
                        this.datagrid('reload');
                    }
                });
            }
        }
    </script>

    <!-- -->
    <table id="@tableName" class="easyui-datagrid" style="width:100%" rownumbers="true" fitColumns="true" fit="true"
           pagination="true" pageSize="@SystemSettingService.Instance.PageSize" pageList="@SystemSettingService.Instance.PageList"
           data-options="striped:true,border:false,singleSelect:true,url:'~/@plugName/Terms/GetTerms',method:'get',toolbar:'#@tableToolBar'">
        <thead>
            <tr>
                <th data-options="field:'_edit',align:'center',formatter:function(v,r,i){
                        return GridRowEditFmt('@editFunName', r.Id);
                    }" width="45"></th>
                <th data-options="field:'_remove',align:'center',formatter:function(v,r,i){
                        return GridRowDeleteFmt('@deleteFunName', r.Id);
                    }" width="45"></th>
                <th data-options="field:'No',width:160">编号</th>
                <th data-options="field:'TermsTypeID',width:120,formatter:function(v,r,i){
                    var u = GetObject(v, '~/@plugName/Terms/GetTermsTypeByID');
                    if(u != null) { return u.Name; }
                }">类别</th>
                <th data-options="field:'Name',width:160">协议名称</th>
                <th data-options="field:'Version',width:100">协议版本</th>
                <th data-options="field:'Status',width:80">状态</th>
                <th data-options="field:'IsPublished',width:80">是否发布</th>
                <th data-options="field:'EditorUserID',width:120,formatter:function(v,r,i){
                    var u = GetObject(v, '~/Systems/GetUserByID');
                    if(u != null&&u.User != null) { return u.User.FullName; }
                }">修改人</th>
                <th data-options="field:'CreatedTime',width:160,align:'center',formatter:$.DateTimeFmt">修改时间</th>
            </tr>
        </thead>
    </table>
    <div id="@tableToolBar" class="easyui-panel table-toolbar">
        <a href="javascript:@editFunName ()" class="easyui-linkbutton t-btn"><i class="fa fa-plus-circle" style="color:green"></i><span>新增</span></a>
    </div>
</div>